#include "RsGisLibRGISSpatiLocaExt.h"
#include "ExtensionManager.h"
#include "ExtensionSession.h"
#include <QVariant>

RsGisLibRGISSpatiLocaExt::RsGisLibRGISSpatiLocaExt(RsgisPortal* ClientPortal, QWidget *parent)
{
	ui = new Ui::RsGisLibRGISSpatiLocaExt();
	ui->setupUi(this);

	Portal = ClientPortal;

	connect(ui->pushButton_InputFilePath, SIGNAL(clicked()), this, SLOT(on_action_Button_InputFilePath_clicked()));
	connect(ui->pushButton_Excecute, SIGNAL(clicked()), this, SLOT(on_action_Button_Excecute_clicked()));

	ui->lineEdit_InputFilePath->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\In");

	ui->lineEdit_ratBand->setText("0");
	ui->lineEdit_maxXColX->setText("maxXColX");
	ui->lineEdit_maxXColY->setText("maxXColY");
	ui->lineEdit_maxYColX->setText("maxYColX");
	ui->lineEdit_maxYColY->setText("maxYColY");
	ui->lineEdit_minXColX->setText("minXColX");
	ui->lineEdit_minXColY->setText("minXColY");
	ui->lineEdit_minYColX->setText("minYColX");
	ui->lineEdit_minYColY->setText("minYColY");

	ui->lineEdit_Priority->setText("16");
}

void RsGisLibRGISSpatiLocaExt::on_action_Button_InputFilePath_clicked()
{
	QString str = QFileDialog::getOpenFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_InputFilePath->setText(str.toUtf8());
}

void RsGisLibRGISSpatiLocaExt::on_action_Button_Excecute_clicked()
{
	QList<QVariant> SysParaList;
	SysParaList << QVariant(QString("RsGisLib"));
	SysParaList << QVariant(QString("RasterGIS"));
	SysParaList << QVariant(int(ui->lineEdit_Priority->text().toInt()));

	QList<QVariant> AlgParaList;
	AlgParaList << QVariant(QString("SpatiLocaExt"));
	AlgParaList << QVariant(QString(ui->lineEdit_InputFilePath->text()));
	AlgParaList << QVariant(int(ui->lineEdit_ratBand->text().toInt()));
	AlgParaList << QVariant(QString(ui->lineEdit_minXColX->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_minXColY->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_maxXColX->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_maxXColY->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_minYColX->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_minYColY->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_maxYColX->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_maxYColY->text()));

	QVariantList ArgList;
	ArgList << (QVariant)SysParaList;
	ArgList << (QVariant)AlgParaList;

	Portal->goAhead(ArgList);
}